diff -ru core.org/adb/sysdeps.h core/adb/sysdeps.h
--- core.org/adb/sysdeps.h	2016-11-07 10:10:52.000000000 +0100
+++ core/adb/sysdeps.h	2016-11-07 16:57:55.952716945 +0100
@@ -25,6 +25,7 @@
 #endif
 
 #include <errno.h>
+#include <sys/syscall.h>
 
 #include <string>
 #include <vector>
@@ -810,7 +811,7 @@
 
 static __inline__ unsigned long adb_thread_id()
 {
-    return (unsigned long)gettid();
+    return syscall(__NR_gettid);
 }
 
 #endif /* !_WIN32 */
diff -ru core.org/base/errors_unix.cpp core/base/errors_unix.cpp
--- core.org/base/errors_unix.cpp	2016-11-07 10:10:52.000000000 +0100
+++ core/base/errors_unix.cpp	2016-11-07 10:44:15.217399254 +0100
@@ -17,6 +17,7 @@
 #include "android-base/errors.h"
 
 #include <errno.h>
+#include <string.h>
 
 namespace android {
 namespace base {
diff -ru core.org/base/file.cpp core/base/file.cpp
--- core.org/base/file.cpp	2016-11-07 10:10:52.000000000 +0100
+++ core/base/file.cpp	2016-11-07 10:44:35.901793592 +0100
@@ -20,6 +20,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <string.h>
 
 #include <string>
 
diff -ru core.org/base/logging.cpp core/base/logging.cpp
--- core.org/base/logging.cpp	2016-11-07 10:10:52.000000000 +0100
+++ core/base/logging.cpp	2016-11-07 10:45:12.527487064 +0100
@@ -21,6 +21,7 @@
 #include "android-base/logging.h"
 
 #include <libgen.h>
+#include <string.h>
 
 // For getprogname(3) or program_invocation_short_name.
 #if defined(__ANDROID__) || defined(__APPLE__)
